package com.bomberman.items;

import com.bomberman.environment.BombWorld;
import java.awt.Color;
import info.gridworld.actor.*;
import info.gridworld.grid.*;

public class Bomb extends Actor
//Bomb, laid by Man, triggers explosion (BOOM) after 3 turns
{
	int fuse;
	int pwr;
	Color clr;
	
	BombWorld w;

	public Bomb(int Pwr, Color Clr, BombWorld world)
	{
		fuse = 3;
		pwr = Pwr;
		clr = Clr;
		setColor(clr);
		w=world;
	}
	
	public void act()
	//timer, explodes after fuse runs out
	{
		if(fuse==0)
		{	
			explode();
		}
		else
			fuse--;
	}
	
	public void explode()
	//crates BOOM at bomb's former location, and activates a + pattern explosion of BOOMs
	{
	Location Loc = getLocation();
	removeSelfFromGrid();
	BOOM start = new BOOM(w,clr);
	w.add(Loc, start);
	start.explode(pwr);
	}
	
	public int getPwr()
	{return pwr;}
	
	public int getFuse()
	{return fuse;}
	
	public String getImageSuffix()
	{if (fuse==0) return "_burst";
	else return "";}
}